package com.google.android.gcm.demo.app;

import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;

public class PreferenzeActivity extends Activity {

	private CheckBox notificheCheckBox;
	private Button conferma;
	private Button annulla;

	private SharedPreferences settings;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_preferenze);
		settings = getSharedPreferences("PREFERENZE_APP_RSS", Context.MODE_PRIVATE);

		conferma=(Button)findViewById(R.id.buttonConfermaPreferenze);
		annulla=(Button)findViewById(R.id.buttonAnnullaPreferenze);

		notificheCheckBox=(CheckBox)findViewById(R.id.checkBoxNotifiche);
		notificheCheckBox.setChecked(settings.getBoolean("ATTIVA_NOTIFICHE", true));

		conferma.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				SharedPreferences.Editor editor = settings.edit();
				editor.putBoolean("ATTIVA_NOTIFICHE", notificheCheckBox.isChecked() );
				System.out.println("is checked:"+notificheCheckBox.isChecked());
				editor.commit();
				onBackPressed();
			}
		});

		annulla.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				onBackPressed();
			}
		});

	}
}
